package pattern.structrual.facade;

/**
 * 对外访问的门面
 *
 * @Author Gavin
 * @date 2020.07.16 12:12
 */
public class GiftExchangeServiceFacade {
    //这些注入可以通过spring来管理
    private QualifyService qualifyService = new QualifyService();//注入校验逻辑service
    private PointPaymentService pointPaymentService = new PointPaymentService();//注入支付service
    private ShippingService shippingService = new ShippingService();//注入物流service

    public void giftExchange(PointGift pointGift) {//该门面对外提供暴露的服务，这种方式就可以让客户端不需要关心每一个service的实现逻辑了，方便解耦
        //首先进行积分校验
        if (qualifyService.isAvailable(pointGift)) {
            //进行支付服务
            if (pointPaymentService.pay(pointGift)) {
                //最后进行物流运输
                String shippingNo = shippingService.shipGift(pointGift);
                System.out.println("下单成功，订单号是：" + shippingNo);
            }
        }
    }
}
